import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';

/**
 * 包辅助类
 */

class BundleHelper {
  private readonly TAG: string = 'BundleHelper';

  public getBundleSignatureInfo() { //获取应用包签名信息
    let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
    try {
      bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
        hilog.info(0x0000, this.TAG, 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
      }).catch(err => {
        hilog.error(0x0000, this.TAG, 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
      });
    } catch (err) {
      hilog.error(0x0000, this.TAG, 'getBundleInfoForSelf failed: %{public}s', err.message);
    }
  }
}

let bundleHelper = new BundleHelper();

export default bundleHelper as BundleHelper;
